<%--
  Created by IntelliJ IDEA.
  User: parttime
  Date: 2017/8/19
  Time: 下午16:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../resources.jsp" %>


<html>
<head>
    <title>订单列表</title>
</head>
<body>
<div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">查询条件</h3>
        </div>
        <div class="panel-body">
            <form class="form-inline">
                <div class="form-group">
                    <%--<label for="nick_name">昵称：</label>--%>
                    <input type="text" class="form-control" id="nick_name" name="nick_name"  placeholder="买家名称">
                </div>
                <div class="form-group">
                    <%--<label for="so_no_">订单号：</label>--%>
                    <input type="text" class="form-control" id="so_no_" name="so_no_" placeholder="订单号">
                </div>
                <div class="form-group">
                    <%--<label for="store_name">店铺名称：</label>--%>
                    <input type="text" class="form-control" id="store_name" name="store_name" placeholder="店铺名称">
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-info btn-search">查询</button>
                    <button type="button" class="btn btn-reset btn-default">清空</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="ems_table_content">
    <div class="panel panel-default">
        <div class="panel-heading">订单列表</div>
        <div id="table_tools">
            <div class="form-inline" role="form">
                <button type="button" id="shoporder_info" class="btn btn-outline btn-info">
                    <i class="glyphicon glyphicon-info-sign" aria-hidden="true"></i>
                    查看详情
                </button>
                <%--<button type="button" id="shoporder_modify" class="btn btn-outline btn-primary">--%>
                    <%--<i class="glyphicon glyphicon-edit" aria-hidden="true"></i>--%>
                    <%--修改--%>
                <%--</button>--%>
                <%--<button type="button" id="shoporder_delete" class="btn btn-outline btn-danger">--%>
                    <%--<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>--%>
                    <%--删除--%>
                <%--</button>--%>
            </div>
        </div>
        <table id="shopOrderTable"
               data-url="/ems/shoporder/pagination"
               data-show-export="true">
            <thead>
            <tr>
                <th data-field="state" data-checkbox="true"></th>
                <th data-field="nick_name">买家名称</th>
                <th data-field="so_no_">订单编号</th>
                <th data-field="store_name_">店铺名称</th>
                <th data-field="shipping_amount_">运费</th>
                <th data-field="total_">订单总金额</th>
                <th data-field="so_status_" data-formatter="orderStatusFormat">订单状态</th>
                <th data-field="create_time_" data-width="150px">下单时间</th>
                <th data-field="pay_time_">支付完成时间</th>
            </tr>
            </thead>

        </table>
    </div>
</div>

<script>
    $(function () {
        $("#shopOrderTable").createTable();

        $("#shoporder_info").on("click",function(){

            var selectRows =  $('#shopOrderTable').bootstrapTable('getSelections');
            if (selectRows.length == 0) {
                $.errorAlert("请选择要查看的数据");
                return;
            }
            if (selectRows.length > 1) {
                $.errorAlert("暂时不支持多行数据审核");
                return;
            }

            var rowId =  selectRows[0].id_;

            window.location.href = "/ems/shoporder/info?id="+rowId;
        })

    })
</script>


<script>
    function soTypeFormat(srcValue) {
        if (srcValue == 'sales') {
            return "<span style='color: #040404' >销售订单</span>";
        }
    }

    function orderStatusFormat(srcValue) {
        if (srcValue == 'awaiting_pay') {
            return "<span style='color: #1da7ff;font-weight: bold' >等待支付</span>";
        } else if (srcValue == 'cancelled') {
            return "<span style='color: #ff0e15;font-weight: bold' >取消</span>";
        } else if (srcValue == 'payment_verify') {
            return "<span style='color: #0d10c5;font-weight: bold' >等待支付确认</span>";
        } else if (srcValue == 'awaiting_ship') {
            return "<span style='color: #dfc525;font-weight: bold' >等待发货</span>";
        } else if (srcValue == 'shipped') {
            return "<span style='color: #cd6217;font-weight: bold' >已发货</span>";
        } else if (srcValue == 'completed') {
            return "<span style='color: #3cb371;font-weight: bold' >订单完成</span>";
        }
    }

</script>

</body>
</html>
